home *** CD-ROM | disk | FTP | other *** search
/ Ultra Pack / UltraComputing Partner Applications.iso / SunLabs / tclTK / src / tk4.0 / tests / place.test < prev    next >
Text File  |  1995-06-04  |  6KB  |  182 lines

  1. # This file is a Tcl script to test out the "place" command.  It is
  2. # organized in the standard fashion for Tcl tests.
  3. #
  4. # Copyright (c) 1995 Sun Microsystems, Inc.
  5. #
  6. # See the file "license.terms" for information on usage and redistribution
  7. # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  8. #
  9. # @(#) place.test 1.3 95/06/04 14:23:09
  10.  
  11. if {[info procs test] != "test"} {
  12.     source defs
  13. }
  14.  
  15. foreach i [winfo children .] {
  16.     destroy $i
  17. }
  18. wm geometry . {}
  19. raise .
  20.  
  21. # XXX - This test file is woefully incomplete.  At present, only a
  22. # few of the features are tested.
  23.  
  24. toplevel .t -width 300 -height 200 -bd 0
  25. wm geom .t +0+0
  26. frame .t.f -width 154 -height 84 -bd 2 -relief raised
  27. place .t.f -x 48 -y 38
  28. frame .t.f2 -width 30 -height 60 -bd 2 -relief raised
  29. update
  30.  
  31. test place-1.1 {Tk_PlaceCmd procedure, "info" option} {
  32.     place .t.f2 -x 0
  33.     place info .t.f2
  34. } {-x 0 -relx 0 -y 0 -rely 0 -width {} -relwidth {} -height {} -relheight {} -anchor nw}
  35. test place-1.2 {Tk_PlaceCmd procedure, "info" option} {
  36.     place .t.f2 -x 1 -y 2 -width 3 -height 4 -relx 0.1 -rely 0.2 \
  37.         -relwidth 0.3 -relheight 0.4 -anchor se -in .t.f  \
  38.         -bordermode outside
  39.     place info .t.f2
  40. } {-x 1 -relx 0.1 -y 2 -rely 0.2 -width 3 -relwidth 0.3 -height 4 -relheight 0.4 -anchor se -bordermode outside -in .t.f}
  41.  
  42. test place-2.1 {ConfigureSlave procedure, -height option} {
  43.     list [catch {place .t.f2 -height abcd} msg] $msg
  44. } {1 {bad screen distance "abcd"}}
  45. test place-2.2 {ConfigureSlave procedure, -height option} {
  46.     place forget .t.f2
  47.     place .t.f2 -in .t.f -height 40
  48.     update
  49.     winfo height .t.f2
  50. } {40}
  51. test place-2.3 {ConfigureSlave procedure, -height option} {
  52.     place forget .t.f2
  53.     place .t.f2 -in .t.f -height 120
  54.     update
  55.     place .t.f2 -height {}
  56.     update
  57.     winfo height .t.f2
  58. } {60}
  59.  
  60. test place-3.1 {ConfigureSlave procedure, -relheight option} {
  61.     list [catch {place .t.f2 -relheight abcd} msg] $msg
  62. } {1 {expected floating-point number but got "abcd"}}
  63. test place-3.2 {ConfigureSlave procedure, -relheight option} {
  64.     place forget .t.f2
  65.     place .t.f2 -in .t.f -relheight .5
  66.     update
  67.     winfo height .t.f2
  68. } {40}
  69. test place-3.3 {ConfigureSlave procedure, -relheight option} {
  70.     place forget .t.f2
  71.     place .t.f2 -in .t.f -relheight .8
  72.     update
  73.     place .t.f2 -relheight {}
  74.     update
  75.     winfo height .t.f2
  76. } {60}
  77.  
  78. test place-4.1 {ConfigureSlave procedure, -relwidth option} {
  79.     list [catch {place .t.f2 -relwidth abcd} msg] $msg
  80. } {1 {expected floating-point number but got "abcd"}}
  81. test place-4.2 {ConfigureSlave procedure, -relwidth option} {
  82.     place forget .t.f2
  83.     place .t.f2 -in .t.f -relwidth .5
  84.     update
  85.     winfo width .t.f2
  86. } {75}
  87. test place-4.3 {ConfigureSlave procedure, -relwidth option} {
  88.     place forget .t.f2
  89.     place .t.f2 -in .t.f -relwidth .8
  90.     update
  91.     place .t.f2 -relwidth {}
  92.     update
  93.     winfo width .t.f2
  94. } {30}
  95.  
  96. test place-5.1 {ConfigureSlave procedure, -width option} {
  97.     list [catch {place .t.f2 -width abcd} msg] $msg
  98. } {1 {bad screen distance "abcd"}}
  99. test place-5.2 {ConfigureSlave procedure, -width option} {
  100.     place forget .t.f2
  101.     place .t.f2 -in .t.f -width 100
  102.     update
  103.     winfo width .t.f2
  104. } {100}
  105. test place-5.3 {ConfigureSlave procedure, -width option} {
  106.     place forget .t.f2
  107.     place .t.f2 -in .t.f -width 120
  108.     update
  109.     place .t.f2 -width {}
  110.     update
  111.     winfo width .t.f2
  112. } {30}
  113.  
  114. test place-6.1 {ReconfigurePlacement procedure, computing position} {
  115.     place forget .t.f2
  116.     place .t.f2 -in .t.f -x -2 -relx .5 -y 3 -rely .4
  117.     update
  118.     winfo geometry .t.f2
  119. } {30x60+123+75}
  120. test place-6.2 {ReconfigurePlacement procedure, position rounding} {
  121.     place forget .t.f2
  122.     place .t.f2 -in .t.f -x -1.4 -y -2.3
  123.     update
  124.     winfo geometry .t.f2
  125. } {30x60+49+38}
  126. test place-6.3 {ReconfigurePlacement procedure, position rounding} {
  127.     place forget .t.f2
  128.     place .t.f2 -in .t.f -x 1.4 -y 2.3
  129.     update
  130.     winfo geometry .t.f2
  131. } {30x60+51+42}
  132. test place-6.4 {ReconfigurePlacement procedure, position rounding} {
  133.     place forget .t.f2
  134.     place .t.f2 -in .t.f -x -1.6 -y -2.7
  135.     update
  136.     winfo geometry .t.f2
  137. } {30x60+48+37}
  138. test place-6.5 {ReconfigurePlacement procedure, position rounding} {
  139.     place forget .t.f2
  140.     place .t.f2 -in .t.f -x 1.6 -y 2.7
  141.     update
  142.     winfo geometry .t.f2
  143. } {30x60+52+43}
  144. test place-6.6 {ReconfigurePlacement procedure, position rounding} {
  145.     frame .t.f3 -width 100 -height 100 -bg #f00000 -bd 0
  146.     place .t.f3 -x 0 -y 0
  147.     raise .t.f2
  148.     place forget .t.f2
  149.     place .t.f2 -in .t.f3 -relx .303 -rely .406 -relwidth .304 -relheight .206
  150.     update
  151.     winfo geometry .t.f2
  152. } {31x20+30+41}
  153. catch {destroy .t.f3}
  154. test place-6.7 {ReconfigurePlacement procedure, computing size} {
  155.     place forget .t.f2
  156.     place .t.f2 -in .t.f -width 120 -height 89
  157.     update
  158.     list [winfo width .t.f2] [winfo height .t.f2]
  159. } {120 89}
  160. test place-6.8 {ReconfigurePlacement procedure, computing size} {
  161.     place forget .t.f2
  162.     place .t.f2 -in .t.f -relwidth .4 -relheight .5
  163.     update
  164.     list [winfo width .t.f2] [winfo height .t.f2]
  165. } {60 40}
  166. test place-6.9 {ReconfigurePlacement procedure, computing size} {
  167.     place forget .t.f2
  168.     place .t.f2 -in .t.f -width 10 -relwidth .4 -height -4 -relheight .5
  169.     update
  170.     list [winfo width .t.f2] [winfo height .t.f2]
  171. } {70 36}
  172. test place-6.10 {ReconfigurePlacement procedure, computing size} {
  173.     place forget .t.f2
  174.     place .t.f2 -in .t.f -width 10 -relwidth .4 -height -4 -relheight .5
  175.     place .t.f2 -width {} -relwidth {} -height {} -relheight {}
  176.     update
  177.     list [winfo width .t.f2] [winfo height .t.f2]
  178. } {30 60}
  179.  
  180. catch {destroy .t}
  181. concat
  182.